package com.ruoyi.petSys.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.petSys.entity.dto.PromAdoptionDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import com.ruoyi.petSys.mapper.PromAdoptionMapper;
import com.ruoyi.petSys.domain.PromAdoption;
import com.ruoyi.petSys.service.IPromAdoptionService;

/**
 * 发布领养Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-03-22
 */
@Service
public class PromAdoptionServiceImpl implements IPromAdoptionService 
{
    @Autowired
    private PromAdoptionMapper promAdoptionMapper;

    @Autowired
    private TokenService tokenService;

    /**
     * 查询发布领养
     * 
     * @param id 发布领养主键
     * @return 发布领养
     */
    @Override
    public PromAdoptionDto selectPromAdoptionById(Long id)
    {
        return promAdoptionMapper.selectPromAdoptionById(id);
    }

    /**
     * 查询发布领养列表
     * 
     * @param promAdoption 发布领养
     * @return 发布领养
     */
    @Override
    public List<PromAdoptionDto> selectPromAdoptionList(PromAdoption promAdoption)
    {
        return promAdoptionMapper.selectPromAdoptionList(promAdoption);
    }

    /**
     * 新增发布领养
     * 
     * @param promAdoption 发布领养
     * @return 结果
     */
    @Override
    public int insertPromAdoption(PromAdoption promAdoption)
    {
        promAdoption.setPromTime(DateUtils.getNowDate());
        promAdoption.setPromUserId(SecurityUtils.getUserId());
        promAdoption.setIsAdoption(0);

        return promAdoptionMapper.insertPromAdoption(promAdoption);
    }

    /**
     * 修改发布领养
     * 
     * @param promAdoption 发布领养
     * @return 结果
     */
    @Override
    public int updatePromAdoption(PromAdoption promAdoption)
    {
        promAdoption.setUpdateTime(DateUtils.getNowDate());
        return promAdoptionMapper.updatePromAdoption(promAdoption);
    }

    /**
     * 批量删除发布领养
     * 
     * @param ids 需要删除的发布领养主键
     * @return 结果
     */
    @Override
    public int deletePromAdoptionByIds(Long[] ids)
    {
        return promAdoptionMapper.deletePromAdoptionByIds(ids);
    }

    /**
     * 删除发布领养信息
     * 
     * @param id 发布领养主键
     * @return 结果
     */
    @Override
    public int deletePromAdoptionById(Long id)
    {
        return promAdoptionMapper.deletePromAdoptionById(id);
    }
}
